package com.ypan.monitor;

import java.util.ArrayList;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.ypan.monitor.test.TestFragment;

public class MainFragmentAdapter extends FragmentPagerAdapter {
	private ArrayList<Integer> mTitleList;
	private Context mCtx;
	private ArrayList<BaseFragment> mFragments = new ArrayList<BaseFragment>();

	public MainFragmentAdapter(Context ctx, FragmentManager fm) {
		super(fm);
		mCtx = ctx;
		mTitleList = new ArrayList<Integer>();
		mTitleList.add(0, R.string.tab_title_0);
		mTitleList.add(1, R.string.tab_title_1);
		mTitleList.add(2, R.string.tab_title_2);
		mTitleList.add(3, R.string.tab_title_3);
		mTitleList.add(4, R.string.tab_title_4);
		mTitleList.add(5, R.string.tab_title_5);
		mFragments.add(0, TestFragment.newInstance(100));
		mFragments.add(1, TestFragment.newInstance(101));
		mFragments.add(2, TestFragment.newInstance(102));
		mFragments.add(3, TestFragment.newInstance(103));
		mFragments.add(4, TestFragment.newInstance(104));
		mFragments.add(5, TestFragment.newInstance(105));
	}

	@Override
	public Fragment getItem(int pos) {
		return mFragments.get(pos);
	}

	@Override
	public int getCount() {
		return mTitleList.size();
	}

	public CharSequence getPageTitle(int pos) {
		return mCtx.getResources().getString(mTitleList.get(pos));
	}

	public int getTitleID(int pos) {
		return mTitleList.get(pos);
	}

}
